/**
 * @copyright SilverBiology, LLC
 * @author SilverBiology, LLC
 * @website http://www.silverbiology.com
*/
Ext.ns('Taxamatch');

Taxamatch.SearchMenu = function(config){
	
	var store = new Ext.data.TreeStore({
			model: 'SearchMenu'
		,	proxy: {
					type: 'ajax'
				,	url: 'getSearchMenu.json'  // 'getSearchMenu.json',
				,	reader: {
							type: 'tree'
						,	root: 'data'
					}
			}
	});
	
	Ext.apply(this, config, { 
			getDetailCard: this.addDetailCards 
		,	store: store
		,	toolbar: {
					title: 'Taxamatch'
			}
		,	listeners:{
					itemtap: function(list, index,item,e){
						var text = e.target.innerHTML;
					}
			}				
	});
		
	Taxamatch.SearchMenu.superclass.constructor.call(this, config);

};

Ext.extend(Taxamatch.SearchMenu, Ext.NestedList, {

	addDetailCards: function(record, parentRecord) {
		var text = record.attributes.record.data.text;
		
		switch(text) {
			case 'Search':
				Ext.getCmp('mainPanel').setActiveItem(2);
				break;

			case 'About':
				Ext.getCmp('mainPanel').setActiveItem(1);
				break;
		}
	}

});